package com.hubu.util;
import java.util.*;
public class ArrayUtils {
    public static<T> void swap(T array[],int left,int right){
        T temp=array[left];
        array[left]=array[right];
        array[right]=temp;
    }
    public static <T> List<T> asList(T ... value){
        List<T> list=new ArrayList<>();
        if(value!=null&&value.length>0){
            for(T item:value){
                list.add(item);
            }
        }
        return list;
    }
    public static <T> Set<T> asHashSet(T ...value){
        Set<T> set=new HashSet<>();
        if(value!=null&&value.length>0){
            for(T item:value){
                set.add(item);
            }
        }
        return set;
    }
    public static <T> Set<T> asTreeSet(T ...value){
        Set<T> set=new TreeSet<>();
        if(value!=null&&value.length>0){
            for(T item:value){
                set.add(item);
            }
        }
        return set;
    }
    public static <K> Map<K,K> coverToMap(K ...value) {
        Map<K, K> map = new HashMap<>();
        if (value != null && value.length > 0) {
            for (K item : value) {
                map.put(item, item);
            }
        }
        return map;
    }
    public static int random(int low,int high) {
        int v = high - low;
        Random random = new Random();
        int result = random.nextInt(v) + low;
        return result;
    }

    public static void main(String[] args) {
        Random random=new Random();
        //
        //1 到99
        int array[]=new int[100];
        for(int i=1;i<=10000000;i++){
            int value = random(1, 100);
            array[value]++;
        }
        for(int i=1;i<=99;i++){
            System.out.println(array[i]);
        }
    }
}
